\subsubsection{Memory Semantics of Library Functions}
\label{upc-flag-t}
\index{memory consistency}
\index{UPC\_OUT\_ALLSYNC}
\index{UPC\_OUT\_MYSYNC}
\index{UPC\_OUT\_NOSYNC}
\index{UPC\_IN\_ALLSYNC}
\index{UPC\_IN\_MYSYNC}
\index{UPC\_IN\_NOSYNC}
\index{upc\_flag\_t}

\npf{\tt upc\_flag\_t} is an integral type defined in {\tt<upc.h>} which is used to
    control the data synchronization semantics of certain collective
    UPC library functions.  Values of function arguments
    having type {\tt upc\_flag\_t} are formed by or-ing together a
    constant of the form {\tt UPC\_IN\_{\em X}SYNC} and a constant of
    the form {\tt UPC\_OUT\_{\em Y}SYNC}, where {\tt{\em X}} and {\tt
    {\em Y}} may be {\tt NO}, {\tt MY}, or {\tt ALL}.

\np If an argument of type {\tt upc\_flag\_t} has value
    {\tt (UPC\_IN\_{\em X}SYNC}$\;|\;${\tt UPC\_OUT\_{\em Y}SYNC)},
    then if {\tt{\em X}} is

\begin{description}
    \item[{\tt NO}] the function may begin to read or write
    data when the first thread has entered the collective function call,

    \item[{\tt MY}] the function may begin to read or write only
    data which has affinity to threads that have entered the collective
    function call, and

    \item[{\tt ALL}] the function may begin to read or write
    data only after all threads have entered
    the function call\footnote{{\tt UPC\_IN\_ALLSYNC} requires the
    function to guarantee that
    after all threads have entered the function call all
    threads will read the same values of the input data.}
\end{description}

\np and if {\tt{\em Y}} is

\begin{description}
    \item[{\tt NO}] the function may read and write data until
    the last thread has returned from the collective function call,

    \item[{\tt MY}] the function call may return in a thread
    only after all reads and writes of data with affinity to the thread
    are complete\footnote{{\tt UPC\_OUT\_MYSYNC} requires the 
  function to guarantee that after a thread returns from the
  function call the thread will not read any earlier values of the
  output data with affinity to that thread.}, and

    \item[{\tt ALL}] the function call may return only after
  all reads and writes of data are complete.\footnote{{\tt UPC\_OUT\_ALLSYNC}
  requires the collective function to guarantee that after a thread returns
  from the function call the thread will not read any earlier
  values of the output data.

  {\tt UPC\_OUT\_ALLSYNC} is not required to provide an ``implied"
  barrier.  For example, if the entire operation has been
  completed by a certain thread before some other threads have reached
  their corresponding function calls, then that thread may exit its call.}
\end{description}

\np Passing {\tt UPC\_IN\_{\em X}SYNC} alone has the same effect as
   {\tt (UPC\_IN\_{\em X}SYNC}$\;|\;${\tt UPC\_OUT\_ALLSYNC)},
   passing {\tt UPC\_OUT\_{\em X}SYNC} alone has the same effect as
   {\tt (UPC\_IN\_ALLSYNC}$\;|\;${\tt UPC\_OUT\_{\em X}SYNC)},
   and passing 0 has the same effect as
   {\tt (UPC\_IN\_ALLSYNC}$\;|\;${\tt UPC\_OUT\_ALLSYNC)},
   where {\tt{\em X}} is {\tt NO}, {\tt MY}, or {\tt ALL}.
   
\np Each of the six flags {\tt UPC\_\{IN,OUT\}\_\{NO,MY,ALL\}SYNC} are
   macros which expand to integer constant expressions.  The expressions
   are defined such that bitwise ORs of all combinations of the macros result
   in distinct positive values less than 64.
